package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.StudentDao;
import com.itheima.domain.Student;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public void save(Student student) {
        studentDao.save(student);
    }

    @Override
    public void delete(Integer studentno) {
        studentDao.delete(studentno);
    }

    @Override
    public void update(Student student) {
        studentDao.update(student);
    }

    @Override
    public Student findById(Integer studentno) {
        return studentDao.findById(studentno);
    }

    @Override
    public PageInfo<Student> findAll(int page, int size) {
        PageHelper.startPage(page, size);
        List<Student> all = studentDao.findAll();
        return new PageInfo<Student>(all);
    }

    @Override
    public List<Student> findByGradeid(Integer gradeid) {
        return studentDao.findByGradeid(gradeid);
    }
}
